package keer.httpinterface.http;

/**
 * http连接配置类，用于在{@link HttpRequester}设置http连接的相关配置
 * @see HttpRequester
 */
public class HttpProperties {
    public HttpProperties() {

    }

    public HttpProperties(HttpProperties httpProperties) {
        this.connectionKeepAliveMillis = httpProperties.connectionKeepAliveMillis;
        this.maxConnections = httpProperties.maxConnections;
        this.initialConnections = httpProperties.initialConnections;
        this.readTimeoutMillis = httpProperties.readTimeoutMillis;
        this.writeTimeoutMillis = httpProperties.writeTimeoutMillis;
        this.waitConnectionTimeoutMillis = httpProperties.waitConnectionTimeoutMillis;
        this.cache = httpProperties.cache;
        this.connectTimeoutMillis = httpProperties.connectTimeoutMillis;
    }
    /**
     * 初始化连接数
     */
    private Integer initialConnections = 2;
    /**
     * 最大连接数
     */
    private Integer maxConnections = 10;
    /**
     * 连接保持时间
     */
    private Long connectionKeepAliveMillis = 30000L;
    /**
     * 等待连接超时时间
     */
    private Long waitConnectionTimeoutMillis = 2000L;
    /**
     * 连接超时时间
     */
    private Long connectTimeoutMillis = 5000L;
    /**
     * 读超时时间
     */
    private Long readTimeoutMillis = 2000L;
    /**
     * 写超时时间
     */
    private Long writeTimeoutMillis = 5000L;
    /**
     * 是否开启缓存
     */
    private Boolean cache = Boolean.FALSE;
//
//    public String getRequesterClass() {
//        return requesterClass;
//    }
//
//    public void setRequesterClass(String requesterClass) {
//        this.requesterClass = requesterClass;
//    }

    /**
     * 最大连接数
     * @return Integer 最大连接数
     */
    public Integer getMaxConnections() {
        return maxConnections;
    }

    /**
     * 设置最大连接数
     * @param maxConnections 最大连接数
     */
    public void setMaxConnections(Integer maxConnections) {
        this.maxConnections = maxConnections;
    }

    /**
     * 连接保持时间
     * @return Long 连接保持时间(毫秒数)
     */
    public Long getConnectionKeepAliveMillis() {
        return connectionKeepAliveMillis;
    }

    /**
     * 设置连接保持时间
     * @param connectionKeepAliveMillis 连接保持时间(毫秒数)
     */
    public void setConnectionKeepAliveMillis(Long connectionKeepAliveMillis) {
        this.connectionKeepAliveMillis = connectionKeepAliveMillis;
    }

    /**
     * 连接超时时间
     * @return Long 连接超时时间(毫秒数)
     */
    public Long getConnectTimeoutMillis() {
        return connectTimeoutMillis;
    }

    /**
     * 设置连接超时时间
     * @param connectTimeoutMillis 连接超时时间(毫秒数)
     */
    public void setConnectTimeoutMillis(Long connectTimeoutMillis) {
        this.connectTimeoutMillis = connectTimeoutMillis;
    }

    /**
     * 读超时时间
     * @return Long 读超时时间(毫秒数)
     */
    public Long getReadTimeoutMillis() {
        return readTimeoutMillis;
    }

    /**
     * 设置读超时时间
     * @param readTimeoutMillis 读超时时间(毫秒数)
     */
    public void setReadTimeoutMillis(Long readTimeoutMillis) {
        this.readTimeoutMillis = readTimeoutMillis;
    }

    /**
     * 写超时时间
     * @return Long 写超时时间(毫秒数)
     */
    public Long getWriteTimeoutMillis() {
        return writeTimeoutMillis;
    }

    /**
     * 设置写超时时间
     * @param writeTimeoutMillis 写超时时间(毫秒数)
     */
    public void setWriteTimeoutMillis(Long writeTimeoutMillis) {
        this.writeTimeoutMillis = writeTimeoutMillis;
    }

    /**
     * 是否开启缓存
     * @return Boolean 是否开启缓存
     */
    public Boolean getCache() {
        return cache;
    }

    /**
     * 设置是否开启缓存
     * @param cache 是否开启缓存
     */
    public void setCache(Boolean cache) {
        this.cache = cache;
    }

    /**
     * 初始化连接数
     * @return Integer 初始化连接数
     */
    public Integer getInitialConnections() {
        return initialConnections;
    }

    /**
     * 设置初始化连接数
     * @param initialConnections 初始化连接数
     */
    public void setInitialConnections(Integer initialConnections) {
        this.initialConnections = initialConnections;
    }

    /**
     * 等待连接超时时间
     * @return Long 等待连接超时时间(毫秒数)
     */
    public Long getWaitConnectionTimeoutMillis() {
        return waitConnectionTimeoutMillis;
    }

    /**
     * 设置等待连接超时时间
     * @param waitConnectionTimeoutMillis 等待连接超时时间(毫秒数)
     */
    public void setWaitConnectionTimeoutMillis(Long waitConnectionTimeoutMillis) {
        this.waitConnectionTimeoutMillis = waitConnectionTimeoutMillis;
    }
}
